<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}{% endblock title %}</title>
    
    {{ bootstrap.load_css() }}
    <!-- 设置网页背景颜色 -->
    <link rel="stylesheet" href="{{ url_for('static', filename='css/init.css') }}">
    {{ bootstrap.load_js() }}
    {% block head %}{% endblock head %}
</head>

<body>

    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="#">橘子问答</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
                aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse" id="navbarSupportedContent">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/">首页 <span class="sr-only">(current)</span></a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{url_for('qa.public_question')}}">发布问答</a>
                    </li>

                    <li class="nav-item ml-5">
                        <form class="form-inline my-2 my-lg-0" method="get" action="{{url_for('qa.search')}}">
                            <input class="form-control mr-sm-2" type="search" placeholder="请输入关键字" aria-label="Search" name="search_query" value="{{request.args.get('search_query')}}">
                            <button class="btn btn-outline-success my-2 my-sm-0" type="submit">搜索</button>
                        </form>
                    </li>
                </ul>

                <ul class="navbar-nav">
                    {% if user %}
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('user.about_info', user_id=user.id) }}">{{user.username}}</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{url_for('user.logout')}}">退出登陆</a>
                        </li>
                    {% else %}
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('user.login') }}">登陆</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('user.register') }}">注册</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>
    <div class="container">
        {% block content %}

        {% endblock content %}
    </div>
</body>
</html>